package com.gblfy.qywxin.vo;

/**
 * 返回封装对象
 *
 * @author gblfy
 * @date 2022-01-12
 */
public class JsonData {
    /**
     * 业务上的成功或失败
     */
    private boolean success = true;
    private Integer code;
    private String msg;
    private Object data;

    public JsonData() {

    }

    public JsonData(Integer code, Object data, String msg,boolean success) {
        this.code = code;
        this.data = data;
        this.msg = msg;
        this.success = success;

    }

    public static JsonData buildSuccess() {
        return new JsonData(0, null, null,true);
    }

    public static JsonData buildSuccess(Object data) {
        return new JsonData(0, data, null,true);
    }

    public static JsonData buildError(String msg) {
        return new JsonData(-1, null, msg,false);
    }

    public static JsonData buildError(Integer code, String msg) {
        return new JsonData(code, null, msg,false);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
    public boolean getSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }
}
